package org.jactao.rpc;

import org.jactao.common.LReferConfig;

import java.lang.reflect.Proxy;

/**
 * Created by fanzetao on 2018/4/10.
 */
public class LProxyFactory {

    private static LProxyFactory factory = new LProxyFactory();

    private LProxyFactory() {
    }

    public static LProxyFactory getInstance() {
        return factory;
    }

    public <T> T proxy(LReferConfig referConfig) {
        return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                new Class[]{referConfig.getInterfaceClass()}, new LProxy(referConfig));
    }

}
